<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Order extends CI_Controller {


	public function __construct()
	{
	  	parent::__construct();
	  	$this->load->model(array('order_model'));
	}
	
	/**
	 * [index 生成订单]
	 * @return [type] [description]
	 */
	public function index()
	{
		if(!empty($_POST['demand'])){
			$data = $this->input->post();
			$_GET['pid'] <= 1  ? $_insert['price'] = 0 : $_insert['price'] = 300;
			$_insert['demand']	     = $data['demand'];
			$_insert['place_date']   = time();
			$_insert['order_number'] = date('YmdHis').$this->input->get('cid').$this->input->get('pid');
			$_insert['member_id']	 = $_SESSION['member_id'];
			$_insert['pro_id']	 	 = $this->input->get('pid');
			$_insert['cid']	 		 = $this->input->get('cid');
			$_insert['status']	 	 = 3;
			if($this->order_model->insert($_insert)){
				echo '提交成功';
			}else{
				echo '提交失败';
			}
		}
		$this->load->view('home/order/index');
	}


}

